﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TGVR.DataHelper.BussinessObject.BookingSystem;

namespace TGVR_Boot.Services
{
    public class ServiceBootAirAsia : IBoot
    {
        AirAsiaServiceBoot.ServiceBootClient BootViaService = new AirAsiaServiceBoot.ServiceBootClient();
        private string m_Code;
        private int m_Total;
        private DateTime m_HoldToDate;

        public List<BK_Ticket> Search(string _strStationForm, string _strStationTo, DateTime _dtDateFrom, DateTime? _dtDateTo, int _iAdut, int _iChild, int _iBaby, bool _isInter, int _iUserID)
        {
            var re = BootViaService.Search(_strStationForm, _strStationTo, _dtDateFrom, _dtDateTo, _iAdut, _iChild, _iBaby, _isInter, _iUserID).ToList();
            BootViaService.Close();
            return re;
        }

        public List<BK_Ticket> SearchCheapest(string _strStationForm, string _strStationTo, DateTime _dtDateFrom, DateTime? _dtDataTo, int _iAdut, int _iChild, int _iBaby, int _iUserID)
        {
            var re = BootViaService.SearchCheapest(_strStationForm, _strStationTo, _dtDateFrom, _dtDataTo, _iAdut, _iChild, _iBaby, _iUserID).ToList();
            BootViaService.Close();
            return re;
        }

        public int MakeBooking(BK_Booking booking, BK_Passenger[] passenges, BK_Ticket tkDepart, BK_Ticket tkReturn, int _iUserID)
        {
            var re = BootViaService.MakeBooking(booking, passenges, tkDepart, tkReturn, _iUserID);
            m_Code = re.Code;
            m_Total = (int)re.Price;
            m_HoldToDate = re.HoldToDate;
            BootViaService.Close();
            return re.Status;
        }

        public string GetCode()
        {
            return m_Code;
        }

        public int GetTotal()
        {
            return m_Total;
        }

        public DateTime GetHoldToDate()
        {
            return m_HoldToDate;
        }

        public BookingResult MakeBookingResult(BK_Booking booking, BK_Passenger[] passenges, BK_Ticket tkDepart, BK_Ticket tkReturn, int _iUserID)
        {
            throw new NotImplementedException();
        }
    }
}
